package com.comp490.bullet;

import android.graphics.Canvas;
import android.graphics.Paint;

import com.comp490.shooter.GameView;
import com.comp490.sprite.Collidable;
import com.comp490.sprite.Ship;

/**
 * Abstract class from which all bullets are extended.
 * 
 * @author Alexandru Rosu <alexandru.rosu.75@gmail.com>
 */
public abstract class Bullet implements Collidable
{
    /**
     * Strength of the bullet.
     */
    protected int damage;

    /**
     * X coordinate.
     */
    protected float x;

    /**
     * Y coordinate.
     */
    protected float y;

    protected boolean active;
    
    protected float radius;

    /**
     * Paint to draw the bullet with.
     */
    protected Paint paint;

    /**
     * Constructor.
     * 
     * @param x
     *            x coordinate
     * @param y
     *            y coordinate
     */
    public Bullet(float x, float y, int dmg, boolean act)
    {
        this.x = x;
        this.y = y;
        damage = dmg;
        active = act;
    }

    public boolean isActive()
    {
        return active;
    }

    public void setActive(boolean active)
    {
        this.active = active;
    }

    /**
     * Returns x coordinate.
     * 
     * @return float value of x coordinate
     */
    public float getX()
    {
        return x;
    }

    /**
     * Returns y coordinate.
     * 
     * @return float value of x coordinate
     */
    public float getY()
    {
        return y;
    }

    /**
     * Returns the damage value of this bullet.
     * 
     * @return damage value.
     */
    public int getDamage()
    {
        return damage;
    }

    /**
     * Modify x coordinate.
     * 
     * @param x
     *            value to be set
     */
    public void setX(float x)
    {
        this.x = x;
    }

    /**
     * Modify y coordinate.
     * 
     * @param y
     *            value to be set
     */
    public void setY(float y)
    {
        this.y = y;
    }

    /**
     * Decides if the bullet is inside the bounds of screen or not.
     * 
     * @param g
     *            GameView object that knows the size of the screen.
     * 
     * @return true if the bullet is within the bounds reported by GameView,
     *         false otherwise.
     */
    public abstract boolean boundsCheck(GameView g);

    /**
     * Decides if the bullet collided with a Collidable object.
     * 
     * @param c
     *            Collidable object to check against.
     * @return true if the bullet is close enough to cause a collision with the
     *         Collidable object, false otherwise.
     */
    public abstract boolean collisionCheck(Ship ship);

    /**
     * Draws the graphic for this bullet to the given canvas.
     * 
     * @param c
     *            canvas to draw to.
     */
    public abstract void draw(Canvas c);
}